package com.kotiln.lgc.guidepagedemo.viewpager;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;

import androidx.fragment.app.Fragment;

import com.kotiln.lgc.guidepagedemo.MainActivity;
import com.kotiln.lgc.guidepagedemo.R;

public class ContentFragment extends Fragment {
    private int[] images = {R.drawable.image1, R.drawable.image2, R.drawable.image3, R.drawable.image4};

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_content, null);
        Button btn = view.findViewById(R.id.btn);
        RelativeLayout rl = view.findViewById(R.id.rl);

        int index = getArguments().getInt("index");
        rl.setBackgroundResource(images[index]);
        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                startActivity(new Intent(getActivity(), MainActivity.class));
            }
        });

        btn.setVisibility(index == 3 ? View.VISIBLE : View.GONE);
        return view;
    }
}